using System;
using System.Windows.Forms;

namespace TimeLineControl
{
    public partial class FrmConfigColor : Form
    {
        private bool _cancel;

        public FrmConfigColor()
        {
            InitializeComponent();
        }

        private void LbkTimeColor_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            ColorDialog.Color = LblColorTime.ForeColor;
            ColorDialog.ShowDialog();
            LblColorTime.ForeColor = ColorDialog.Color;
            LblColorBalance.ForeColor = ColorDialog.Color;
        }

        private void LnkFcPrgOkLinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            ColorDialog.Color = PnlOkF.BackColor;
            ColorDialog.ShowDialog();
            PnlOkF.BackColor = ColorDialog.Color;
        }

        private void LnkFcPrgNokLinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            ColorDialog.Color = PnlNOkF.BackColor;
            ColorDialog.ShowDialog();
            PnlNOkF.BackColor = ColorDialog.Color;
        }

        private void ConfigColor_Load(object sender, EventArgs e)
        {
            LblAlert.BackColor = DataConfigTimeLine.AlertBackGroundColor;
            LblAlert.ForeColor = DataConfigTimeLine.AlertTextColor;
            LblColorTime.ForeColor = DataConfigTimeLine.FormTextColorInboundColor;
            LblColorTime.BackColor = DataConfigTimeLine.FormBackGroundColor;
            LblColorBalance.ForeColor = DataConfigTimeLine.FormTextColorInboundColor;
            LblColorBalance.BackColor = DataConfigTimeLine.FormBackGroundColor;
            PnlOkF.BackColor = DataConfigTimeLine.ProgressBarInboundColor;
            PnlOkB.BackColor = DataConfigTimeLine.FormBackGroundColor;
            PnlNOkF.BackColor = DataConfigTimeLine.ProgressBarOutboundColorNeg;
            PnlNOkB.BackColor = DataConfigTimeLine.FormBackGroundColor;
            PnlOkBB.BackColor = DataConfigTimeLine.FormBackGroundColor;
            PnlOkFB.BackColor = DataConfigTimeLine.ProgressBarOutboundColorPos;
        }
        private void ConfigColor_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (!_cancel)
            {
                DataConfigTimeLine.AlertBackGroundColor = LblAlert.BackColor;
                DataConfigTimeLine.AlertTextColor = LblAlert.ForeColor;
                DataConfigTimeLine.FormTextColorInboundColor = LblColorTime.ForeColor;
                DataConfigTimeLine.FormBackGroundColor = LblColorTime.BackColor;
                DataConfigTimeLine.ProgressBarOutboundColorNeg = PnlNOkF.BackColor;
                DataConfigTimeLine.ProgressBarInboundColor = PnlOkF.BackColor;
                DataConfigTimeLine.ProgressBarOutboundColorPos = PnlOkFB.BackColor;
            }
        }

        private void Button1Click(object sender, EventArgs e)
        {
            _cancel = true;
            Close();
        }

        private void Button2Click(object sender, EventArgs e)
        {
            Close();
        }

        private void LnkBackGroundFrmClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            ColorDialog.Color = LblColorTime.BackColor;
            ColorDialog.ShowDialog();
            LblColorTime.BackColor = ColorDialog.Color;
            LblColorBalance.BackColor = ColorDialog.Color;
            PnlOkB.BackColor = ColorDialog.Color;
            PnlNOkB.BackColor = ColorDialog.Color;
            PnlOkBB.BackColor = ColorDialog.Color;
        }

        private void LnkFcPrgOkbLinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            ColorDialog.Color = PnlOkFB.BackColor;
            ColorDialog.ShowDialog();
            PnlOkFB.BackColor = ColorDialog.Color;
        }

        private void LnkBackGroundAlert_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            ColorDialog.Color = PnlAlert.BackColor;
            ColorDialog.ShowDialog();
            LblAlert.BackColor = ColorDialog.Color;
        }

        private void LbkAlertColor_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            ColorDialog.Color = LblAlert.ForeColor;
            ColorDialog.ShowDialog();
            LblAlert.ForeColor = ColorDialog.Color;
        }
    }
}